package cn.tedu.health.controller;

import cn.tedu.health.pojo.entity.SocialFeatures;
import cn.tedu.health.response.JsonResult;
import cn.tedu.health.service.ISocialFeaturesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
public class SocialFeaturesController {

    @Autowired
    private ISocialFeaturesService socialFeaturesService;

    @PostMapping("/socialfeatures")
    public JsonResult createSocialFeature(@RequestBody SocialFeatures socialFeatures) {
        socialFeaturesService.createSocialFeature(socialFeatures);
        return JsonResult.ok();
    }

    @GetMapping("/socialfeatures")
    public JsonResult getSocialFeaturesByUserId(@RequestParam Long userId) {
        List<SocialFeatures> socialFeaturesList = socialFeaturesService.getSocialFeaturesByUserId(userId);
        return JsonResult.ok(socialFeaturesList);
    }

    @GetMapping("/socialfeatures/{userId}/{friendId}")
    public JsonResult getSocialFeaturesByUserIdAndFriendId(@PathVariable Long userId, @PathVariable Long friendId) {
        List<SocialFeatures> socialFeaturesList = socialFeaturesService.getSocialFeaturesByUserIdAndFriendId(userId, friendId);
        return JsonResult.ok(socialFeaturesList);
    }
}
